﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;

namespace JasLib.Threading
{
    /// <summary>
    /// A convenient use of monitor locking based on the "using" statement,
    /// which has far fewer language restraints than the "lock" statement.
    /// </summary>
    public class DisposePatternMonitorLock : IDisposable
    {
        public IDisposable Lock()
        {
            Monitor.Enter(this);
            return this;
        }

        void IDisposable.Dispose()
        {
            Monitor.Exit(this);
            return;
        }
    }
}
